#+TITLE:  Emacs Literate Config
#+AUTHOR: rxf4el
#+EMAIL:  rxf4e1@tuta.io 

#+STARTUP: overview

* Header
#+BEGIN_SRC emacs-lisp
  ;;; config.el --- Generated by config.org -*- coding: utf-8 ; lexical-binding: t -*-
  ;; Author: rxf4e1
  ;; URL:
  ;; Version: 1.00

  ;; This program is free software: you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
  ;; the Free Software Foundation, either version 3 of the License, or
  ;; (at your option) any later version.

  ;; This program is distributed in the hope that it will be useful,
  ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ;; GNU General Public License for more details.
  ;; You should have received a copy of the GNU General Public License
  ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  ;;; Commentary:
  ;;; Code:
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#+END_SRC

* Package Manager
** Leaf
 #+BEGIN_SRC emacs-lisp
   ;; <leaf-install-code>
   (eval-and-compile
     (customize-set-variable
      'package-archives '(("org" . "https://orgmode.org/elpa/")
        ("melpa" . "https://melpa.org/packages/")
        ("gnu" . "https://elpa.gnu.org/packages/")))
     (package-initialize)
     (unless (package-installed-p 'leaf)
       (package-refresh-contents)
       (package-install 'leaf))

     (leaf leaf-keywords
       :ensure t
       :init
       ;; optional packages if you want to use :hydra, :el-get, :blackout,,,
       (leaf hydra :ensure t)
       (leaf el-get :ensure t)
       (leaf blackout :ensure t)

       :config
       ;; initialize leaf-keywords.el
       (leaf-keywords-init)))
   ;; </leaf-install-code>
 #+END_SRC

* Basic Settings
** Initial Settings
#+BEGIN_SRC emacs-lisp
  (leaf custom-start
    :doc "Define custom initial settings."
    :custom ((user-full-name . "Rafael Mironiuc Marte")
             (user-mail-address . "rxf4e1@tuta.io")
             (user-login-name . "rxf4e1")
             (truncate-lines . t)
             (inhibit-startup-screen . t))
    :config
    ;; Set some variables paths.
    (defconst my:d:org (concat (getenv "HOME") "/Nextcloud/org/"))
    ;; Disable suspend key since it is useless on Emacs server.
    (global-unset-key (kbd "C-z"))
    (global-unset-key (kbd "C-x C-z")))
#+END_SRC

** Better Defaults
#+BEGIN_SRC emacs-lisp
  (leaf better-defaults
    :doc ""
    :custom (cursor-in-non-selected-windows . nil)
    :config
    ;; Viper-Mode - Should i use it?
    ;; It breaks icomplete-vertical-toggle, so i have only one line when press M-x.
    ;; (setq viper-mode t)
    ;; (require 'viper)

    ;; Keep going on Setup now.
    (setq enable-dir-local-variables t
          frame-title-format nil
          frame-resize-pixelwise t
          history-length 500
          history-delete-duplicates t
          require-final-newline t
          delete-selection-mode t
          auto-fill-mode 1
          fill-column 72
          font-lock-maximum-decoration nil
          font-lock-maximum-size nil)

    ;; setq-default variables
    (setq-default tab-always-indent 'complete
                  indent-tabs-mode nil
                  tab-width 2
                  major-mode 'text-mode)

    ;; turn on/off some modes
    (blink-cursor-mode +1)
    (visual-line-mode +1)
    (column-number-mode +1)
    (mouse-avoidance-mode 'banish)


    ;; encoding system
    (prefer-coding-system 'utf-8)
    (set-file-name-coding-system 'utf-8)
    (set-keyboard-coding-system 'utf-8)
    (set-terminal-coding-system 'utf-8)
    (set-language-environment 'utf-8)
    (set-default 'buffer-file-coding-system 'utf-8)

    ;; y/n for answering yes/no questions
    (fset 'yes-or-no-p 'y-or-n-p))
#+END_SRC

** Aesthetics
*** Cursor
#+BEGIN_SRC emacs-lisp
  (leaf customize-cursor
    :doc "Darker mouse, less distracting."
    :config
    (set-face-background 'mouse "#777777"))
#+END_SRC

*** Font
#+BEGIN_SRC emacs-lisp
  (leaf fonts
    :doc ""
    :config
    (set-face-attribute 'default nil :font "Iosevka-10" :width 'Regular))
  ;; (set-face-attribute 'default nil :font "DejaVu Sans Mono-10" :width 'Regular))
#+END_SRC

*** Modeline
#+BEGIN_SRC emacs-lisp
  (leaf spaceline
    :doc ""
    :url ""
    :ensure t
    :config
    (require 'spaceline-config)
    (spaceline-emacs-theme)
    (spaceline-compile
      ;; left side
      '(((buffer-modified
          line-column)
         :fallback evil-state
         :face highlight-face)
        (anzu)
        auto-compile
        (buffer-id remote-host)
        (major-mode)
        (process :when active)
        ((flycheck-error flycheck-warning flycheck-info)
         :when active)
        ;; (minor-modes :when active)
        (version-control :when active))
      ;; right side
      '(which-function
        (python-pyvenv :fallback python-pyenv)
        (purpose)
        (battery :when active)
        (selection-info)
        input-method
        ((buffer-encoding-abbrev
          point-position
          buffer-size)
         :separator " | "
         :priority 96)
        (global :when active)
        (buffer-position))))
#+END_SRC

*** Theme
#+BEGIN_SRC emacs-lisp
  (leaf custom-themes
    :doc ""
    :config
    (leaf tron-legacy-theme
      :doc "Setup Theme."
      :url ""
      :ensure t
      :config
      (setq tron-legacy-theme-dark-fg-bright-comments nil
            tron-legacy-theme-vivid-cursor t
            tron-legacy-theme-softer-bg nil)
      (load-theme 'tron-legacy t)))

    ;; (leaf org-beautify-theme
    ;;   :doc ""
    ;;   :url ""
    ;;   :ensure t
    ;;   :config 
    ;;   (load-theme 'org-beautify 'no-confirm)
    ;;   ))
#+END_SRC

*** Custom-Faces
#+BEGIN_SRC emacs-lisp
  (leaf custom-set-faces
    :doc ""
    :config
    (leaf org-custom-faces
      :doc ""
      :config
      (custom-theme-set-faces
       'user
       '(org-block                 ((t (:inherit fixed-pitch))))
       '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
       '(org-property-value        ((t (:inherit fixed-pitch))) t)
       '(org-special-keyword       ((t (:inherit (font-lock-comment-face fixed-pitch)))))
       '(org-tag                   ((t (:inherit (shadow fixed-pitch) :weight bold))))
       '(org-verbatim              ((t (:inherit (shadow fixed-pitch)))))
       `(org-agenda-structure      ((t (:inherit default :height 2.0 :underline nil))))
       `(org-level-8               ((t (:inherit fixed-pitch))))
       `(org-level-7               ((t (:inherit fixed-pitch))))
       `(org-level-6               ((t (:inherit fixed-pitch))))
       `(org-level-5               ((t (:inherit fixed-pitch))))
       `(org-level-4               ((t (:inherit fixed-pitch))))
       `(org-level-3               ((t (:inherit fixed-pitch  :box))))
       `(org-level-2               ((t (:inherit fixed-pitch :height 1.15 :box))))
       `(org-level-1               ((t (:inherit fixed-pitch :height 1.35  :box))))
       `(org-document-title        ((t (:inherit org-level-1 :height 1.7 :underline nil :box))))
       '(variable-pitch            ((t (:family "Iosevka Medium" :height 120 :weight normal))))
       '(fixed-pitch               ((t (:family "Iosevka Light" :slant normal :weight normal :height 0.9 :width normal)))))))
#+END_SRC

*** Line Numbers
#+BEGIN_SRC emacs-lisp
  ;; (leaf display-line-numbers
  ;;   :doc ""
  ;;   :hook ((emacs-lisp-mode-hook . display-line-numbers-mode))
  ;;   :custom (display-line-numbers . 'relative)
  ;;   :config
  ;;   (display-line-numbers-mode t)
  ;;   )
#+END_SRC

* General Settings
** Built-Ins
*** Auto-Revert
#+BEGIN_SRC emacs-lisp
  (leaf autorevert
    :doc "revert buffers when files on disk change"
    :tag "builtin"
    :custom ((auto-revert-interval . 0.1))
    :global-minor-mode global-auto-revert-mode)
#+END_SRC

*** Buffers
**** Display
#+BEGIN_SRC emacs-lisp
  (leaf minibuffers
    :doc "MiniBuffer customizations.")
#+END_SRC

**** iBuffer
#+BEGIN_SRC emacs-lisp
  (leaf ibuffer
    :doc ""
    :bind ("C-x C-b" . ibuffer)
    :config
    (leaf all-the-icons-ibuffer
      :doc ""
      :ensure t
      :init (all-the-icons-ibuffer-mode 1)))
#+END_SRC
**** Uniquify
#+BEGIN_SRC emacs-lisp
  (leaf uniquify
    :doc ""
    :config
    (setq uniquify-buffer-name-style 'post-forward-angle-brackets
          uniquify-separator "/"
          uniquify-after-kill-buffer-p t
          uniquify-ignore-buffers-re "*[^*]+*"))
#+END_SRC

*** Icomplete
#+BEGIN_SRC emacs-lisp
  (leaf icomplete
    :doc "Icomplete Mode"
    :init (icomplete-mode -1)
    :config
    (setq icomplete-separator " | "
          icomplete-delay-completions-threshold 0
          icomplete-max-delay-chars 0
          icomplete-compute-delay 0
          icomplete-show-matches-on-no-input t
          icomplete-hide-common-prefix nil
          icomplete-in-buffer t
          icomplete-prospects-height 1
          icomplete-with-completion-tables t
          completion-styles '(initials flex))
    :bind (:icomplete-minibuffer-map
           ("<down>" . icomplete-forward-completions)
           ("C-n"    . icomplete-forward-completions)
           ("<up>"   . icomplete-backward-completions)
           ("C-p"    . icomplete-backward-completions)))

  (leaf icomplete-vertical
    :doc ""
    :ensure t
    :after icomplete
    :init (icomplete-vertical-mode -1)
    :config
    (setq read-file-name-completion-ignore-case t)
    (setq read-buffer-completion-ignore-case t)
    (setq completion-ignore-case t)
    (setq completion-styles '(partial-completion substring))
    (setq completion-category-overrides '((file (styles basic substring))))
    (icomplete-mode 1)
    :bind  (:icomplete-minibuffer-map
            ("C-v"    . icomplete-vertical-toggle)))
#+END_SRC

*** Ediff
*** ElDoc
#+BEGIN_SRC emacs-lisp
  (leaf eldoc
    :doc ""
    :hook (after-init-hook . global-eldoc-mode))
#+END_SRC

*** Dired
#+BEGIN_SRC emacs-lisp
  (leaf dired
    :doc ""
    :config
    (leaf all-the-icons-dired
      :doc ""
      :ensure t
      :hook (dired-mode-hook . all-the-icons-dired-mode)))
#+END_SRC

*** TODO Dabbrev
*** Hippie-Expand
#+BEGIN_SRC emacs-lisp
  (leaf hippie-expand
    :doc "Try Hippie-Expand for sane completions"
    :bind ("M-SPC" . hippie-expand)
    :config
    (setq hippie-expand-verbose t
          hippie-expand-try-functions-list
          '(yas/hippie-try-expand
            try-complete-file-name-partially
            try-expand-all-abbrevs
            try-expand-dabbrev
            try-expand-dabbrev-all-buffers
            try-expand-dabbrev-from-kill
            try-complete-lisp-symbol-partially
            try-complete-lisp-symbol)))
#+END_SRC

*** Parenthesis
#+BEGIN_SRC emacs-lisp
  (leaf parenthesis
    :doc ""
    :config
    (leaf parens
      :doc "Show Paren"
      :hook (after-init-hook . show-paren-mode)
      :config
      (setq show-paren-style 'parenthesis
            show-paren-when-point-in-periphery nil
            show-paren-when-point-inside-paren nil)
      )
    (leaf electric-pairs
      :doc "Builtin way to easily insert matching delimiters."
      :hook (after-init-hook . (lambda ()
                                 (electric-indent-mode 1)
                                 (electric-pair-mode 1)
                                 (electric-quote-mode 1)))
      :config
      (setq electric-pair-inhibit-predicate'electric-pair-conservative-inhibit
            electric-pair-preserve-balance t)
      (setq electric-pair-pairs
            '((8216 . 8217)
              (8220 . 8221)
              (171 . 187)))
      (setq electric-pair-skip-self 'electric-pair-default-skip-self)
      (setq electric-pair-skip-whitespace nil)
      (setq electric-pair-skip-whitespace-chars
            '(9
              10
              32))
      (setq electric-quote-context-sensitive t)
      (setq electric-quote-paragraph t)
      (setq electric-quote-string nil)
      (setq electric-quote-replace-double t)))
#+END_SRC

*** Recentf
#+BEGIN_SRC emacs-lisp
  (leaf recentf
    :doc "Open recent files list."
    :bind ("C-x C-r" . recentf-open-files)
    :config
    (setq recentf-max-menu-items 10
          recentf-max-saved-items 10)
    (recentf-mode 1))
#+END_SRC

*** Save Place
#+BEGIN_SRC emacs-lisp
  (leaf save-place
    :doc ""
    :config
    (save-place-mode 1))
#+END_SRC

*** Skeleton
#+BEGIN_SRC emacs-lisp
  (leaf skeleton
    :doc "")
#+END_SRC

*** Tramp
#+BEGIN_SRC emacs-lisp
  (leaf tramp
    :doc "")
#+END_SRC

*** Uniquify
#+BEGIN_SRC emacs-lisp
  (leaf uniquify
    :doc ""
    :config
    (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
    (setq uniquify-separator "/")
    (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
    (setq uniquify-ignore-buffers-re "*[^*]+*") ; don't muck with special buffers
    )
#+END_SRC

*** Wind-Move
#+BEGIN_SRC emacs-lisp
  (leaf wind-move
    :doc ""
    :bind (("s-<up>"    . windmove-up)
           ("s-<down>"  . windmove-down)
           ("s-<left>"  . windmove-left)
           ("s-<right>" . windmove-right)
           ("s-<tab>"   . next-multiframe-window)
           ("M-<tab>" . next-buffer)))
#+END_SRC

** 3rd-Parties
*** Auto Indent
#+BEGIN_SRC emacs-lisp
  (leaf aggressive-indent
    :doc ""
    :ensure t
    :config
    (global-aggressive-indent-mode 1))
#+END_SRC

*** Avy
#+BEGIN_SRC emacs-lisp
  (leaf avy
    :doc ""
    :url "https://github.com/abo-abo/avy"
    :ensure t
    :bind (("C-:" . avy-goto-char)
           ("C-*" . avy-resume)
           ("M-g M-g" . avy-goto-line))
    :config
    (leaf avy-zap
      :doc ""
      :bind ([remap zap-to-char] . avy-zap-to-char)))
#+END_SRC

*** Company
#+BEGIN_SRC emacs-lisp
  (leaf company
    :doc ""
    :ensure t
    :hook ((lsp-mode . company-mode)
           (after-init-hook . global-company-mode))
    :config
    (setq company-backends
          '((company-files
             company-keywords
             company-capf)
            (company-abbrev company-dabbrev))
          company-minimum-prefix-length 1
          company-idle-delay 0.0
          company-begin-commands '(self-insert-command)
          company-selection-wrap-around t
          company-show-numbers t))
#+END_SRC

*** Expand-Region
#+BEGIN_SRC emacs-lisp
  (leaf expand-region
    :doc ""
    :ensure t
    :bind (("C-=" . er/expand-region)
           ("C--" . er/contract-region)))
#+END_SRC

*** Flycheck
#+BEGIN_SRC emacs-lisp
  (leaf flycheck
    :doc ""
    :ensure t
    :init global-flycheck-mode
    :config
    (setq flycheck-emacs-lisp-load-path 'inherit)
    (setq flycheck-check-syntax-automatically '(save mode-enabled idle-buffer-switch))
    (setq flycheck-buffer-switch-check-intermediate-buffers t)
    (setq flycheck-display-errors-delay 0.25))
#+END_SRC

*** Graphviz
*** Lsp
#+BEGIN_SRC emacs-lisp
  (leaf lsp-mode
    :doc ""
    :ensure t
    :commands lsp
    :bind (:lsp-mode-map ("C-c C-f" . lsp-format-buffer))
    :hook ((java-mode python-mode go-mode
                      js-mode js2-mode web-mode
                      c-mode nix-mode r-mode
                      julia-mode) . lsp)
    :config
    (lsp-auto-guess-root nil)
    (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
    (lsp-file-watch-threshold 2000)
    (read-process-output-max (* 1024 1024))
    (lsp-eldoc-hook nil))

  (leaf lsp-ui
    :doc ""
    :after lsp-mode
    :commands lsp-ui-mode
    :bind ((:lsp-ui-mode-map
            ([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
            ([remap xref-find-references] . lsp-ui-peek-find-references)
            ("C-c u" . lsp-ui-imenu)
            ("M-i" . lsp-ui-doc-focus-frame))
           (:lsp-mode-map
            ("M-n" . forward-paragraph)
            ("M-p" . backward-paragraph)))
    :config
    (lsp-ui-doc-header t)
    (lsp-ui-doc-include-signature t)
    (lsp-ui-doc-border (face-foreground 'default))
    (lsp-ui-sideline-enable nil)
    (lsp-ui-sideline-ignore-duplicate t)
    (lsp-ui-sideline-show-code-actions nil)
    ;; Use lsp-ui-doc-webkit only in GUI
    (if (display-graphic-p)
        (setq lsp-ui-doc-use-webkit t))
    ;; WORKAROUND Hide mode-line of the lsp-ui-imenu buffer
    ;; https://github.com/emacs-lsp/lsp-ui/issues/243
    (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
      (setq mode-line-format nil)))
#+END_SRC

*** Magit
#+BEGIN_SRC emacs-lisp
  (leaf magit
    :doc ""
    :ensure t
    :bind ("C-x g" . magit-status))
#+END_SRC

*** Multiple-Cursor
#+begin_src emacs-lisp
  (leaf multiple-cursors
    :doc ""
    :ensure t)
#+end_src

*** Ollivetti
#+BEGIN_SRC emacs-lisp
  (leaf olivetti
    :doc ""
    :ensure t)
#+END_SRC

*** Snippets
#+BEGIN_SRC emacs-lisp
  (leaf yasnippet
    :doc ""
    :ensure t
    :init (yas-global-mode 1)
    :setq (yas-snippet-dirs . '("~/.emacs.d/snippets")))
#+END_SRC

*** Which-Key
#+begin_src emacs-lisp
  (leaf which-key
    :doc ""
    :ensure t
    :setq
    (which-key-idle-delay . 0.5)
    (which-key-idle-secondary-delay . 0.1)
    :custom
    (which-key-setup-side-window-bottom)
    :config
    (which-key-mode 1))
#+end_src

** Coding
*** Data Bases
**** SQL
#+BEGIN_SRC emacs-lisp
  (leaf data-bases
    :doc "Databases Setup"
    :config
    (leaf emacsql-sqlite
      :doc "SQLite"
      :ensure t))
#+END_SRC

*** Org-Mode
**** Org-Defaults
#+BEGIN_SRC emacs-lisp
  (leaf org
    :doc ""
    :ensure t
    :hook ((org-mode-hook . org-indent-mode)
           (org-mode-hook . auto-fill-mode)
           (org-mode-hook . prettify-symbols-mode)
           (org-mode-hook . (lambda ()
                              (variable-pitch-mode 1)
                              visual-line-mode)))
    :bind (("C-c o a" . org-agenda)
           ("C-c o c" . org-capture))
    :config
    (setq org-directory my:d:org)
    (setq org-startup-indented t
          org-src-tab-acts-natively t)
    (setq org-hide-emphasis-markers t
          org-fontify-done-headline t
          org-hide-leading-stars t
          org-pretty-entities t
          org-odd-levels-only t
          org-src-window-setup 'split-window-below)

    (font-lock-add-keywords 'org-mode
                            '(("^ *\\([-]\\) "
                               (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
    (font-lock-add-keywords 'org-mode
                            '(("^ *\\([+]\\) "
                               (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "◦"))))))
    (setq-default prettify-symbols-alist '(("#+BEGIN_SRC" . "†")
                                           ("#+END_SRC" . "†")
                                           ("#+begin_src" . "†")
                                           ("#+end_src" . "†")
                                           (">=" . "≥")
                                           ("=>" . "⇨")))
    (setq prettify-symbols-unprettify-at-point 'right-edge)
    (setq org-todo-keywords
          '((sequence "TODO(t)" "|" "DONE(D)" "CANCEL(C)")
            (sequence "MEET(m)" "|" "MET(M)")
            (sequence "STUDY(s)" "|" "STUDIED(S)")
            (sequence "WRITE(w)" "|" "WROTE(W)")))
    (setq org-todo-keyword-faces
          '(("MEET" . '(font-lock-preprocessor-face org-todo))
            ("STUDY" . '(font-lock-variable-name-face org-todo))
            ("WRITE" . '(font-lock-type-face org-todo))))
    (setq org-priority-faces
          '((?A . '(org-scheduled-today org-priority))
            (?B . org-priority)
            (?C . '(shadow org-priority)))))
#+END_SRC

**** Org-Agenda
#+BEGIN_SRC emacs-lisp
(leaf org-agenda
  :doc ""
  :bind ("C-c o a" . org-agenda))
#+END_SRC

**** Org-Babel
#+BEGIN_SRC emacs-lisp
  (leaf org-babel
    :doc ""
    :config
    (setq org-babel-load-languages
          '((shell . t)
            (emacs-lisp . t)
            ;; (python . t)
            ;; (R . t)
            ;; (dot . t)
            )))
#+END_SRC

**** Org-Capture
**** Org-Noter
#+BEGIN_SRC emacs-lisp
  (leaf org-noter
    :doc ""
    :ensure t
    :after (org pdf-view)
    :config
    (setq
     ;; The WM can handle splits
     org-noter-notes-window-location 'horizontal-split ; vertical-split / other-frame
     ;; Please stop opening frames
     org-noter-always-create-frame t
     ;; I want to see the whole file
     org-noter-hide-other nil
     ;; Everything is relative to the main notes file
     org-noter-notes-search-path (list "~/Nextcloud/Org/")))
#+END_SRC

**** Org-Ref
#+BEGIN_SRC emacs-lisp
  (leaf org-ref
    :doc ""
    :ensure t
    :config
    (require 'org-ref)
    (setq reftex-default-bibliography "~/Nextcloud/Org/ref/library.bib"
          org-ref-default-bibliography '("~/Nextcloud/Org/ref/library.bib")
          org-ref-bibliography-notes "~/Nextcloud/Org/ref/notes/bibnotes.org"
          org-ref-pdf-directory "~/Nextcloud/Org/ref/pdf/"))
#+END_SRC

**** Org-Roam
#+BEGIN_SRC emacs-lisp
  (leaf org-roam
    :doc ""
    :url ""
    :ensure t
    :hook (org-mode-hook . org-roam-mode)
    :bind ((:org-roam-mode-map
            (("C-c n l" . org-roam)
             ("C-c n f" . org-roam-find-file)
             ("C-c n g" . org-roam-graph))
            (:org-mode-map
             (("C-c n i" . org-roam-insert))
             (("C-c n I" . org-roam-insert-immediate)))))
    :config
    (setq org-roam-directory "~/Nextcloud/Org/org-roam/"
          org-roam-db-location "~/Nextcloud/Org/org-roam/org-roam.db")
    (setq org-roam-buffer-position 'right
          org-roam-buffer-width 0.2
          org-roam-verbose nil
          org-roam-buffer-window-parameters '((no-delete-other-windows . t))
          org-roam-completion-system 'helm)
    (add-to-list 'org-roam-capture-templates
                 '(("r" "default" plain (function org-roam--capture-get-point)
                    "%?"
                    :file-name "%<%Y%m%d%H%M%S>-${slug}"
                    :head "#+TITLE: ${title}\n#+ROAM_TAGS: \n\n- tags :: "
                    :unnarrowed t)))
    (leaf org-roam-server
      :doc ""
      :ensure t
      :config
      (setq org-roam-server-host "127.0.0.1"
            org-roam-server-port 8080
            org-roam-server-authenticate nil
            org-roam-server-export-inline-images t
            org-roam-server-serve-files nil
            org-roam-server-served-file-extensions '("pdf" "mp4" "ogv" "jpg" "png")
            org-roam-server-network-poll t
            org-roam-server-network-arrows nil
            org-roam-server-network-label-truncate t
            org-roam-server-network-label-truncate-length 60
            org-roam-server-network-label-wrap-length 20)))
#+END_SRC

**** Org-Superstar
#+BEGIN_SRC emacs-lisp
  (leaf org-superstar
    :doc ""
    :ensure t
    :after org
    :hook (org-mode-hook . org-superstar-mode)
    :config
    (setq org-superstar-prettify-item-bullets t
          org-superstar-item-bullet-alist
          '((?* . ?●)
            (?+ . ?➤)
            (?- . ?—))))
#+END_SRC

**** Deft
#+BEGIN_SRC emacs-lisp
  (leaf deft
    :doc ""
    :url ""
    :ensure t
    :bind ("<f8>" . deft)
    :config
    (setq deft-directory "~/Nextcloud/Org/org-roam/"
          deft-default-extension "org"
          deft-extensions '("org" "md")
          deft-use-filename-as-title nil
          deft-use-filter-string-for-filename t
          deft-auto-save-interval -1.0)
    (setq deft-file-naming-rules
          '((noslash . "-")
            (nospace . "-")
            (case-fn . downcase))))
#+END_SRC

*** TODO Languages
**** Common-Lisp
**** Nix
#+BEGIN_SRC emacs-lisp
  (leaf nix-mode
    :doc "NixOS DSL"
    :ensure t
    :mode ("\\.nix\\'" . nix-mode))
#+END_SRC

**** Scheme
#+BEGIN_SRC emacs-lisp
  (leaf geiser
    :doc "Dialects of Scheme Programming"
    :ensure t)
#+END_SRC

**** Latex
**** R
#+BEGIN_SRC emacs-lisp
  (leaf ess
    :doc ""
    :ensure t
    :config
    (load "ess-autoloads")
    (leaf ess-R-data-view
      :doc ""
      :ensure t))
#+END_SRC

**** Python
#+BEGIN_SRC emacs-lisp
  (leaf elpy
    :doc ""
    :ensure t
    :hook ((flycheck-mode-hook . elpy-mode)
           (elpy-mode . (lambda ()
                          (set (make-local-variable 'company-backends)))))
    :init
    (elpy-enable)
    :config
    (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)
          elpy-shell-echo-output nil
          elpy-rpc-python-command "python3"
          elpy-rpc-timeout 2))
#+END_SRC

**** Markdown
#+BEGIN_SRC emacs-lisp
  (leaf markdown-mode
    :doc ""
    :mode ("\\.md\\'" . gfm-mode))
#+END_SRC

**** Web
#+BEGIN_SRC emacs-lisp
  (leaf htmlize
    :doc ""
    :ensure t)
#+END_SRC

** Readers
*** ePUB
#+BEGIN_SRC emacs-lisp
  (leaf nov
    :doc "Nov.el is an ePUB Reader."
    :ensure t
    :mode ("\\.epub\\'" . nov-mode)
    :config
    (setq nov-text-width 60))
#+END_SRC

*** PDF-Tools
#+BEGIN_SRC emacs-lisp
  (leaf pdf-tools
    :doc ""
    :ensure t
    :init (pdf-tools-install t t t)
    :hook (pdf-view-mode-hook . pdf-view-midnight-minor-mode)
    :setq (pdf-view-midnight-colors . '("#ff9900" . "#0a0a12" )))
#+END_SRC

** Shells
*** Eshell
*** Ansi-Term
#+BEGIN_SRC emacs-lisp
  (leaf ansi-term
    :doc "Ansi-Term Terminal Emulator."
    :config
    (leaf eterm-256color
      :doc ""
      :ensure t
      :hook (term-mode . eterm-256color-mode)))
#+END_SRC

*** Shell-Pop
#+BEGIN_SRC emacs-lisp
  (leaf shell-pop
    :doc ""
    :ensure t
    :bind ("s-<return>" . shell-pop)
    :config
    (setq shell-pop-shell-type (quote ("ansi-term" "*ansi-term*" (lambda nil
                                                                   (ansi-term shell-pop-term-shell)))))
    (setq shell-pop-term-shell "/run/current-system/sw/bin/zsh")
    ;; need to do this manually or not picked up by `shell-pop'
    (shell-pop--set-shell-type 'shell-pop-shell-type shell-pop-shell-type))
#+END_SRC

* Personal Settings
** Config File
#+BEGIN_SRC emacs-lisp

#+END_SRC

** ScreenShots
*** Selected Region
#+BEGIN_SRC emacs-lisp
 (defun rx/take-screenshot-region ()
    "Take a screenshot into a time stamped unique-named file in the
  same directory as the org-buffer and insert a link to this file."
    (interactive)
    (let ((filename
           (concat
            (make-temp-name
             (concat (buffer-file-name)
                     "_"
                     (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")))
      (call-process "scrot" nil nil nil "-s" filename)
      (insert (concat "[[" filename "]]"))
      (org-display-inline-images)))
(global-set-key (kbd "<f12>") 'rx/take-screenshot-region)
#+END_SRC

* Footer
#+BEGIN_SRC emacs-lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; config.el ends here.
#+END_SRC


